n, m = map(int, input().split())
edges = list()
for _ in range(m):
    s, t, v = map(int, input().split())
    edges.append((s, t, v))
inf = float('inf')
minist = [inf] * (n + 1)
src, dst, k = map(int, input().split())
minist[src] = 0
for i in range(k + 1):
    minist_copy = minist[:]
    for fr, to, cost in edges:
        if minist[to] > minist_copy[fr] + cost:
            minist[to] = minist_copy[fr] + cost

if minist[dst] == 'inf':
    print("unreachable")
else:
    print(minist[dst])
